package com.lzs.bootsafety.common.util;

import java.util.HashMap;
import java.util.List;

/**
 * @author zhanshi Liu
 * @date 2020/02/21
 * @website www.jhmsona.cn
 */
public class Resu extends HashMap<String,Object> {
    private static final long serialVersionUID = 1L;
    public Resu(){
        put("code",200);
        put("msg","success");
    }
    public static Resu error(int code,String msg){
        Resu resu = new Resu();
        resu.put("code",code);
        resu.put("msg",msg);
        return  resu;
    }
    public static Resu error(){
        return error(500,"未处理的异常，请联系管理员");
    }
    public static Resu error(String msg){
        return error(500,msg);
    }
    public static Resu page(List data, Long count, Integer code){
        Resu resu = new Resu();
        resu.put("data",data);
        resu.put("count",count);
        resu.put("code",code);
        return resu;
    }
    public static Resu suces(String msg){
        Resu resu = new Resu();
        resu.put("code",200);
        resu.put("msg",msg);
        return  resu;
    }

    public static Resu suces(){
        return new Resu();
    }
    @Override
    public Resu put(String key, Object value){
        super.put(key,value);
        return this;
    }
}
